from vnctptdType661 import *
import globalvar
tickprice=[]
def OnTick(marketdata,arg,):
    print('A: '+str(marketdata))
    print('B: '+str(arg))
    #print('C: '+str(strategyname))



    return [1,1]
    return
    print('OnTick EMA:'+str(marketdata.InstrumentID, encoding="utf-8"))

    if 1:
        print('EMA买')
        # 用限价单 VN_OPT_LimitPrice 方式报单 。通常用涨停价限价单模拟市价，因为市价指令不支持所有的交易所
        exchangeid = globalvar.dict_exchange[str(marketdata.InstrumentID, encoding="utf-8")].split(',')[0]
        result = globalvar.td.InsertOrder(str(marketdata.InstrumentID, encoding="utf-8"), exchangeid, '0', '1',
                                          VN_OPT_LimitPrice, marketdata.LastPrice + 10, 1)
        result = result + globalvar.td.InsertOrder(str(marketdata.InstrumentID, encoding="utf-8"), exchangeid, '0', '0',
                                                   VN_OPT_LimitPrice, marketdata.LastPrice + 10, 1)
        if result == 0:
            print('报单成功')
        else:
            print('报单失败')

        print('S10')
        return [1, 1]
    else:
        print('S11')
        print('EMA卖')
        # 用限价单 VN_OPT_LimitPrice 方式报单 。通常用涨停价限价单模拟市价，因为市价指令不支持所有的交易所
        exchangeid = globalvar.dict_exchange[str(marketdata.InstrumentID, encoding="utf-8")].split(',')[0]
        result = globalvar.td.InsertOrder(str(marketdata.InstrumentID, encoding="utf-8"), exchangeid, '1', '1',
                                          VN_OPT_LimitPrice, marketdata.LastPrice - 10, 1)
        result = result + globalvar.td.InsertOrder(str(marketdata.InstrumentID, encoding="utf-8"), exchangeid, '1', '0',
                                                   VN_OPT_LimitPrice, marketdata.LastPrice - 10, 1)
        print('S12')
        if result == 0:
            print('报单成功')
        else:
            print('报单失败')
        print('S13')
        return [-1, -1]

    return [0, 0]





